<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page import="java.util.*"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
<head>
<title>_装箱信息查询</title>
<script type="text/javascript">
	var datatable_content;
	$(function() {
		$("#queryForm").validate();
		$("#_startTime").datepicker({
			format : 'yyyy-mm-dd'
		});
		$("#_endTime").datepicker({
			format : 'yyyy-mm-dd'
		});
	});
	function getPalletItems(orderNo){
		$.ajax({
			type : 'post',
			url : '${ctx}/v2_pallet/ajaxCheckOrderInfo',
			data : {
				orderno : orderNo
			},
			dataType : 'json',
			success : function(data) {
				var msg = data.msg;
				if (msg == 'success'||msg == 'binding') {
					// 显示订单信息
					var workOrder = data.workOrder;
					getAjaxItems(workOrder.order.id) ; 
				}  
			},
			error : function() {
				alert("网络繁忙，请稍后重试...");
			}
		});
	}
	function excelInfo(){
	     $("#queryForm").attr("action","${ctx}/v2_pallet/excelInfo");
	     $("#queryForm").submit();
	}
	function search_info(){
		$("#queryForm").attr("action","${ctx}/v2_pallet/page2/info");
	    $("#queryForm").submit();
	}
</script>
</head>

<body>
	<section class="content">
		<div class="row">
			<div class="col-md-12">
				<div class="box box-solid box-primary">
					<div class="box-header">
						<i class="fa fa-search"></i>
						<h3 class="box-title">托盘信息</h3>
						<div class="box-tools pull-right">
							<button class="btn btn-primary btn-sm" data-widget="collapse">
								<i class="fa fa-minus"></i>
							</button>
						</div>
					</div>
					<div class="box-body">

						<form class="form-search" action="${ctx}/v2_pallet/page2/info"
							id="queryForm" method="post">
							<div class="form-group row">
								<div class="col-sm-3">
									<div class="input-textgroup  col-sm-12">
										<label class="input-group-text">LPN编码：</label> <input
											class="form-control" id="_lpnNo" name="_lpnNo"
											value="${_lpnNo }">
									</div>
								</div>
								<div class="col-sm-3">
									<div class="input-textgroup  col-sm-12">
										<span class="input-group-text"> 仓库: </span> <select
											name="_warehouseCode" id="_warehouseCode"
											value="${_warehouseCode}" style="width: 157px;"
											class="form-control">
											<option value=""></option>
											<c:forEach items="${warehouseList}" var="wm">
												<option value="${wm.groupCode}"
													<c:if test="${_warehouseCode eq wm.groupCode}">selected=selected</c:if>>${wm.groupName}</option>
											</c:forEach>
										</select>
									</div>
								</div>
								<div class="col-sm-3">
									<div class="input-textgroup  col-sm-12">
										<label class="input-group-text">订单编号：</label> <input
											class="form-control" id="_orderNo" name="_orderNo"
											value="${_orderNo }">
									</div>
								</div>
								<div class="col-sm-3">
									<div class="input-textgroup  col-sm-12">
										<span class="input-group-text"> 装箱状态: </span> <select
											name="_status" id="_status" class="form-control">
											<option value="0"
												<c:if test="${_status eq '0'}">selected=selected</c:if>>解绑</option>
											<option value="1"
												<c:if test="${_status eq '1'}">selected=selected</c:if>>绑定中</option>
										</select>
									</div>
								</div>
							</div>

							<div class="form-group row">
								<div class="col-sm-3">
									<div class="input-textgroup  col-sm-12">
										<label class="input-group-text">装箱批次：</label> <input
											class="form-control" id="_batchSeq" name="_batchSeq"
											value="${_batchSeq }">
									</div>
								</div>
								<div class="col-sm-3">
									<div class="input-textgroup  col-sm-12">
										<label class="input-group-text">装箱日期：</label> <input
											type="text" value="${_startTime }" class="form-control"
											id="_startTime" name="_startTime">
									</div>
								</div>

								<div class="col-sm-3">
									<div class="input-textgroup  col-sm-12">
										<label class="input-group-text">至：</label> <input type="text"
											value="${_endTime }" class="form-control" id="_endTime"
											name="_endTime">
									</div>
								</div>
								<button class="btn btn-info" id="btn-info" onclick="search_info()">搜索</button>
								<button onclick="excelInfo();" class="btn btn-primary">导出到excel</button>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="box box-solid box-primary">
					<div class="box-header">
						<i class="fa fa-list"></i>
						<h3 class="box-title">查询结果</h3>
						<div class="box-tools pull-right">
							<button class="btn btn-primary btn-sm" data-widget="collapse">
								<i class="fa fa-minus"></i>
							</button>
						</div>
					</div>
					<div class="box-body">
						<table id="contentTable"
							class="table table-striped table-bordered table-condensed">
							<thead>
								<tr>
									<th>LPN编号</th>
									<th>托盘名称</th>
									<th>托盘编码</th>
									<th>订单编号</th>
									<th>装箱状态</th>
									<th>装箱批次</th>
									<th>装箱时间</th>
									<th>卸载时间</th>
									<th>订单详情</th>
								</tr>
								<c:if test="${not empty palletOrderList}">
									<c:forEach items="${palletOrderList}" var="palletOrder"
										varStatus="i">
										<tr>
											<td>${palletOrder.lpnNo}</td>
											<td>${palletOrder.name}</td>
											<td>${palletOrder.palletNum}</td>
											<td>${palletOrder.orderNo}</td>
											<td id="status_${palletOrder.status}"><c:if
													test="${palletOrder.status eq 0}">解绑</c:if> <c:if
													test="${palletOrder.status eq 1}">绑定中</c:if></td>
											<td>${palletOrder.batchSeq}</td>
											<td><fmt:formatDate value="${palletOrder.createTime}"
													pattern="yyyy-MM-dd HH:mm:ss" /></td>
											<td><fmt:formatDate value="${palletOrder.last_update_time}"
													pattern="yyyy-MM-dd HH:mm:ss" /></td>
											<td><a data-toggle="modal" href="#orderItemsDetail"
												class="btn btn-info"
												onclick="getPalletItems('${palletOrder.orderNo}');">查看</a></td>
										</tr>
									</c:forEach>
								</c:if>
							</thead>
							<tbody>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
		<!-- 弹出窗体-订单详情 start  -->
		<div id="orderItemsDetail" class="modal fade">
			<div class="modal-dialog" style="width: 60%;">
				<div class="modal-content">

					<div class="modal-body">
						<div class="box box-solid box-primary">
							<div class="box-header">
								<span class="box-title">订单详细信息</span>
							</div>
							<div class="box-body">
								<table
									class="table table-striped table-bordered table-condensed"
									id="modalBodyItems"></table>
							</div>
						</div>
					</div>

				</div>
			</div>
		</div>
		<!-- 弹出窗体-订单详情 end  -->
	</section>
</body>
</html>
